<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Gym Rat | Show Log Entry</title>
<style type="text/css">
@import "${pageContext.request.contextPath}/js/jquery.datepick.css";
</style>
<script type="text/javascript"
	src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.datepick.js"></script>
<script type="text/javascript">
$(function() {
	$('#popupDatepicker').datepick();
});
</script>
</head>
<body>
<jsp:include page="/includes/nav.jsp" />
<h1>Modifying Log Entry for ${log.exerciseName} on <fmt:formatDate
	type='DATE' value='${log.dateWorked}' dateStyle='full' /></h1>
<h2>Change Date (mm/dd/yyyy):</h2>
<form action="edit/submit" method="post"><input type="text"
	name="date"
	value="<fmt:formatDate pattern='MM/dd/yyyy' type='DATE' value='${log.dateWorked}' />"
	id="popupDatepicker"> <br>
<h2>Change Variations:</h2>
<c:forEach var="variation" items="${variations }">
	<input type="radio" name="variationBox" value="${variation.id }"
		<c:if test="${variation.id == log.variationId }">
checked="yes"
</c:if> />
	<c:choose>
		<c:when test="${variation.id == log.variationId }">
			<b>${variation.name }</b>
			<br>
		</c:when>
		<c:otherwise>
			${variation.name }
			<br>
		</c:otherwise>
	</c:choose>
</c:forEach>

<h2>Change Equipment:</h2>
<c:forEach var="equipment" items="${equipment }">
	<input type="radio" name="equipmentBox" value="${equipment.id }"
		<c:if test="${equipment.id == log.equipmentId }">
checked="yes"
</c:if> />
	<c:choose>
		<c:when test="${equipment.id == log.equipmentId }">
			<b>${equipment.name }</b>
			<br>
		</c:when>
		<c:otherwise>
			${equipment.name }
			<br>
		</c:otherwise>
	</c:choose>
</c:forEach>

<h2>Change weight and reps</h2>
<table>
	<tr>
		<td>Set</td>
		<td>Reps</td>
		<td>Weight</td>
		<td>Delete Set</td>
	</tr>
	<c:forEach var="set" items="${log.sets}" varStatus="status">

		<tr>
			<td>${status.count }</td>
			<td><input type="text" name="reps_${set.id }" size="4"
				value="${set.reps }"></td>
			<td><input type="text" name="weight_${set.id }" size="4"
				value="${set.weight }"></td>
			<td><input type="checkbox" name="delete_${set.id }" value="yes"></td>
			<td><input type="hidden" name="sets" value="${set.id }"></td>
		</tr>

	</c:forEach>
</table>
<input type="hidden" name="logId" value="${log.id }"> <input
	type="button" disabled="disabled" value="Add Set">
<hr />
<input type="hidden" name="action" value="update"> <input
	type="button" name="update" value="Update" onClick="submit()">

</form>
<form action="edit/submit" method="post"><input type="hidden"
	name="action" value="delete"><input type="hidden" name="logId"
	value="${log.id }"> <input type="button" name="update"
	value="Delete"
	onClick="if(confirm('Really delete log entry?')) 
	submit()"></form>
</body>
</html>